<template>
  <el-dialog
    title="详情"
    :close-on-click-modal="false"
    append-to-body
    :visible.sync="visible"
    class="jsbos-dialog jsbos-dialog_center"
    lock-scroll
    width="600px"
  >
    <el-row :gutter="15" class="">
      <el-form
        ref="elForm"
        :model="dataForm"
        size="small"
        label-width="100px"
        label-position="right"
      >
        <template v-if="!loading">
          <el-col :span="24">
            <el-form-item label="考试名称" prop="examId">
              <p>{{ dataForm.examId }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="课程名称" prop="courseId">
              <p>{{ dataForm.courseId }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="试卷名称" prop="paperId">
              <p>{{ dataForm.paperId }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="开始时间" prop="startTime">
              <p>{{ jsbos.dateFormat(dataForm.startTime) }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="提交时间" prop="submitTime">
              <p>{{ jsbos.dateFormat(dataForm.submitTime) }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="类型" prop="submitType">
              <p>{{ dataForm.submitType | dynamicText(submitTypeOptions) }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="批阅状态" prop="questionReviewStatus">
              <p>{{ dataForm.questionReviewStatus }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="批阅人" prop="reviewerUserId">
              <p>{{ dataForm.reviewerUserId }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="批阅时间" prop="reviewerTime">
              <p>{{ dataForm.reviewerTime }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="创建用户" prop="creatorUserId">
              <p>{{ dataForm.creatorUserId }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="创建时间" prop="creatorTime">
              <p>{{ dataForm.creatorTime }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="修改用户" prop="lastModifyUserId">
              <p>{{ dataForm.lastModifyUserId }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="修改时间" prop="lastModifyTime">
              <p>{{ dataForm.lastModifyTime }}</p>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label-width="0">
              <div class="jsbos-common-title">
                <h2>答题结果</h2>
              </div>
              <el-table :data="dataForm.temsexamtaskresultList" size="mini">
                <el-table-column
                  type="index"
                  width="50"
                  label="序号"
                  align="center"
                />
                <el-table-column prop="taskId" label="考试记录id">
                  <template slot-scope="scope">
                    <p>{{ scope.row.taskId }}</p>
                  </template>
                </el-table-column>
                <!-- <el-table-column prop="parentId" label="案例题父级ID">
                  <template slot-scope="scope">
                    <p>{{ scope.row.parentId }}</p>
                  </template>
                </el-table-column> -->
                <el-table-column prop="questionId" label="题库试题id">
                  <template slot-scope="scope">
                    <p>{{ scope.row.questionId }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="questionType" label="题型">
                  <template slot-scope="scope">
                    <p>
                      {{
                        scope.row.questionType
                          | dynamicText(questionTypeOptions)
                      }}
                    </p>
                  </template>
                </el-table-column>
                <el-table-column prop="title" label="题干">
                  <template slot-scope="scope">
                    <p>{{ scope.row.title }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="titimgs" label="题干图片视频附件">
                  <template slot-scope="scope">
                    <UploadFz
                      v-model="scope.row.titimgs"
                      disabled
                      detailed
                      :fileSize="5"
                      sizeUnit="MB"
                      :limit="9"
                      buttonText="点击上传"
                    >
                    </UploadFz>
                  </template>
                </el-table-column>
                <el-table-column prop="options" label="选项">
                  <template slot-scope="scope">
                    <p>{{ scope.row.options }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="opimgs" label="选项图片视频附件">
                  <template slot-scope="scope">
                    <UploadFz
                      v-model="scope.row.opimgs"
                      disabled
                      detailed
                      :fileSize="5"
                      sizeUnit="MB"
                      :limit="9"
                      buttonText="点击上传"
                    >
                    </UploadFz>
                  </template>
                </el-table-column>
                <el-table-column prop="answers" label="正确答案">
                  <template slot-scope="scope">
                    <p>{{ scope.row.answers }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="score" label="分值">
                  <template slot-scope="scope">
                    <p>{{ scope.row.score }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="analysis" label="答案解析">
                  <template slot-scope="scope">
                    <p>{{ scope.row.analysis }}</p>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="analysisimgs"
                  label="答案解析图片视频附件"
                >
                  <template slot-scope="scope">
                    <UploadFz
                      v-model="scope.row.analysisimgs"
                      disabled
                      detailed
                      :fileSize="5"
                      sizeUnit="MB"
                      :limit="9"
                      buttonText="点击上传"
                    >
                    </UploadFz>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="optionRandom"
                  label="选项打乱(0-否，1-是)"
                >
                  <template slot-scope="scope">
                    <p>{{ scope.row.optionRandom }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="isMarked" label="是否标记">
                  <template slot-scope="scope">
                    <p>{{ scope.row.isMarked }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="myAnswers" label="我的答案">
                  <template slot-scope="scope">
                    <p>{{ scope.row.myAnswers }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="myScore" label="我的得分">
                  <template slot-scope="scope">
                    <p>{{ scope.row.myScore }}</p>
                  </template>
                </el-table-column>
                <el-table-column prop="description" label="描述">
                  <template slot-scope="scope">
                    <p>{{ scope.row.description }}</p>
                  </template>
                </el-table-column>
              </el-table>
            </el-form-item>
          </el-col>
        </template>
      </el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false"> 取 消</el-button>
    </span>
  </el-dialog>
</template>
<script>
import request from "@/utils/request";
import PrintBrowse from "@/components/print-browse";
import jsbos from "@/utils/jsbos";

export default {
  components: { PrintBrowse },
  props: [],
  data() {
    return {
      visible: false,
      loading: false,
      printBrowseVisible: false,
      printId: "",
      dataForm: {
        id: "",
        examId: "",
        courseId: "",
        paperId: "",
        startTime: "",
        submitTime: "",
        submitType: "",
        questionReviewStatus: 0,
        reviewerUserId: "",
        reviewerTime: "",
        creatorUserId: "",
        creatorTime: "",
        lastModifyUserId: "",
        lastModifyTime: "",
        temsexamtaskresultList: [],
      },
      submitTypeOptions: [
        { fullName: "手动交卷", id: "1" },
        { fullName: "自动交卷", id: "2" },
      ],

      questionTypeOptions: [
        { fullName: "单选题", id: "1" },
        { fullName: "多选题", id: "2" },
        {
          fullName: "判断题",
          id: "3",
        },
        { fullName: "填空题", id: "4" },
        { fullName: "问答题", id: "5" },
        // { fullName: "案例题", id: "6" },
      ],
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    dataInfo(dataAll) {
      let _dataAll = dataAll;
      for (let i = 0; i < _dataAll.temsexamtaskresultList.length; i++) {
        var _list = _dataAll.temsexamtaskresultList[i];
        _list.titimgs = _list.titimgs ? JSON.parse(_list.titimgs) : [];
        _list.opimgs = _list.opimgs ? JSON.parse(_list.opimgs) : [];
        _list.analysisimgs = _list.analysisimgs
          ? JSON.parse(_list.analysisimgs)
          : [];
      }
      this.dataForm = _dataAll;
    },

    init(id) {
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.loading = true;
          request({
            url: "/api/exam/TemsExamTask/detail/" + this.dataForm.id,
            method: "get",
          }).then((res) => {
            this.dataInfo(res.data);
            this.loading = false;
          });
        }
      });
    },
  },
};
</script>
